package org.wesc.boot.service.system.loginlog;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wesc.boot.dao.entity.User;
import org.wesc.boot.dao.querymapper.LoginLogQueryMapper;

import java.util.List;
import java.util.Map;

/**
 * 登录日志服务
 *
 * @author Wesley
 */
@Slf4j
@Service
public class LoginLogQueryService {

    private final LoginLogQueryMapper loginLogQueryMapper;

    @Autowired
    public LoginLogQueryService(LoginLogQueryMapper loginLogQueryMapper) {
        this.loginLogQueryMapper = loginLogQueryMapper;
    }

    /**
     * 获取系统总访问次数
     *
     * @return Long
     */
    public Long findTotalVisitCount() {
        return loginLogQueryMapper.findTotalVisitCount();
    }

    /**
     * 获取系统今日访问次数
     *
     * @return Long
     */
    public Long findTodayVisitCount(){
        return loginLogQueryMapper.findTotalVisitCount();
    }

    /**
     * 获取系统今日访问 IP数
     *
     * @return Long
     */
    public Long findTodayIp() {
        return loginLogQueryMapper.findTodayIp();
    }

    /**
     * 获取系统近七天来的访问记录
     *
     * @param user 用户
     * @return 系统近七天来的访问记录
     */
    public List<Map<String, Object>> findLastSevenDaysVisitCount(User user) {
        return loginLogQueryMapper.findLastSevenDaysVisitCount(user);
    }
}
